Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[.NET] Add initial nullable reference types support #281

Closed
wants to merge 6 commits into from

Conversation

Romfos
Copy link
Contributor

@Romfos Romfos commented Sep 11, 2024

🤔 What's changed?

  • Enable nullable reference types

⚡️ What's your motivation?

🏷️ What kind of change is this?

  • 🏦 Refactoring/debt/DX (improvement to code design, tooling, etc. without changing behaviour)
  • ⚡ New feature (non-breaking change which adds new behaviour)
  • 💥 Breaking change (incompatible changes to the API)

♻️ Anything particular you want feedback on?

n\a

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

@Romfos Romfos changed the title [.NET] Add initial nullable reference type support [.NET] Add initial nullable reference types support Sep 11, 2024
@Romfos
Copy link
Contributor Author

Romfos commented Sep 11, 2024

nullable annotations are still disabled for:
AstBuilder.cs
Token.cs

Motivation:

  1. It required to do changes in Parser that is code generated and will require update BERP
  2. AstBuilder.cs and Token.cs have potential a lot of "null pointer exception" problems that are hidden now. Fix will lead to changes that could be not so backward compatible

by this reason this is only initial support

@Romfos
Copy link
Contributor Author

Romfos commented Sep 11, 2024

Important:
This PR is a "source breaking change".
Nullable annotations could lead to new warnings in code that depends on this library.
For example if external code will try to pass null in not expected places.

functionally library is the same

Copy link

@clrudolphi clrudolphi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed the DTOs created by the AstConverter against the schema for Messages and made a few comments where I found differences.
The AstConverter is a limited implementation of Cucumber.Messages. Eventually we should port this over consuming the Cucumber.Messages types directly.
@Romfos - would love to have your assistance in applying this same nullable annotations to the template that is used to generate the Io.Cucumber.Messages.Types classes.

@Romfos
Copy link
Contributor Author

Romfos commented Sep 12, 2024

please, during review, pay attention for all code base, not only changed files

motivation:

public abstract class StepsContainer(Location location, string keyword, string name, string description, Step[] steps)
    : IHasLocation, IHasDescription, IHasSteps
{
    public Location Location { get; } = location;
    public string Keyword { get; } = keyword;
    public string Name { get; } = name;
    public string Description { get; } = description;
    public IEnumerable<Step> Steps { get; } = steps;
}

should description be nullable here?

@Romfos
Copy link
Contributor Author

Romfos commented Sep 12, 2024

e your assistance in applying this same nullable annotations to the template that is used to generate the Io.Cucumber.Messages.Types classes.

hm, we have a separate library with copy-paste here?

@clrudolphi
Copy link

please, during review, pay attention for all code base, not only changed files

motivation:

public abstract class StepsContainer(Location location, string keyword, string name, string description, Step[] steps)
    : IHasLocation, IHasDescription, IHasSteps
{
    public Location Location { get; } = location;
    public string Keyword { get; } = keyword;
    public string Name { get; } = name;
    public string Description { get; } = description;
    public IEnumerable<Step> Steps { get; } = steps;
}

should description be nullable here?

I'm really not sure. This part of the code base concerns the AST; I'm not knowledgable enough about that section to provide guidance. Gaspar is the expert to depend upon.

@clrudolphi
Copy link

e your assistance in applying this same nullable annotations to the template that is used to generate the Io.Cucumber.Messages.Types classes.

hm, we have a separate library with copy-paste here?

I suspect its a result of how and when the libraries were built. They are not copy-paste, but parallel implementations of the same object model. The one you see in this library is a subset of that in the Cucumber.Messages library.

@Romfos
Copy link
Contributor Author

Romfos commented Sep 15, 2024

I've reviewed the DTOs created by the AstConverter against the schema for Messages and made a few comments where I found differences. The AstConverter is a limited implementation of Cucumber.Messages. Eventually we should port this over consuming the Cucumber.Messages types directly. @Romfos - would love to have your assistance in applying this same nullable annotations to the template that is used to generate the Io.Cucumber.Messages.Types classes.

cucumber/messages#253

@Romfos
Copy link
Contributor Author

Romfos commented Sep 15, 2024

Probably we need to reference them from Cucumber.Messages insted of have this non-compatible copy here

@mpkorstanje
Copy link
Contributor

The latest version of messages has been released. Should be available on NuGet.

https://github.com/cucumber/messages/releases/tag/v26.0.1

@Romfos
Copy link
Contributor Author

Romfos commented Sep 27, 2024

ok, then lets put on hold, until cucumber messages are not updated with NRE

@Romfos Romfos closed this Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants